﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

#if SILVERLIGHT
using System.Windows;
using GameEngineSL.SilverlightCompatibility;
#else
using System.Drawing;
#endif

namespace GameEngine.Worlds
{
    public class Accelerator : Movable, ITick
    {
        private List<Force> forces = new List<Force>();

        /// <summary>
        /// Forces that act upon the Object. Forces increase the speed at every tick.
        /// </summary>
        public List<Force> Forces
        {
            get
            {
                return forces;
            }
        }

        #region ITick Members

        public new void Tick(float seconds)
        {
            PointF forcesSum = new PointF();
            
            foreach (Force f in forces)
            {
                forcesSum.X += f.ForceVector.X;
                forcesSum.Y += f.ForceVector.Y;
            }

            // Increase speed.
            PointF velocity = Velocity;
            velocity.X += forcesSum.X * seconds;
            velocity.Y += forcesSum.Y * seconds;

            base.Tick(seconds);
        }

        #endregion

        
    }
}
